<template>
  <div class="footer">
    <div v-if="showCart">
      <router-link to="/cart" class="white">去看菜单</router-link>
    </div>
    <div v-else>
      你还没有点菜哦，先点菜吧O(∩_∩)O
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'

export default {
  name: 'index',
  computed: mapState(['getFinalMenu']),
  data: function () {
    return {
      showCart: false,
      finalMenuList: this.$store.getters.getFinalMenu
    }
  },
  mounted () {
    this.checkMenuList()
  },
  methods: {
    checkMenuList: function () {
      if (this.finalMenuList && this.finalMenuList.length > 0) {
        this.showCart = true
      } else {
        this.showCart = false
      }
    }
  },
  watch: {
    finalMenuList: function () {
      this.checkMenuList()
    }
  }
}
</script>

<style scoped>
  .footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    background: rgba(0, 0, 0, .5);
    padding: 10px 15px;
    text-align: center;
    color: #fff;
    line-height: 20px;
  }
</style>
